function add_td(data) {
    return "<td>" + data + "</td>";
}
function set_json_data(json,pageno) {
    console.log(json)
    var res = "";
    $.each(json, function (index) {
            var signal = parseInt(json[index].signal);
            //根据信号强弱 dBm 改变信号图标
            if(signal > -85){
                signal = "signal3.png";
            }else if(signal < -85 && signal >= -95){
                signal = "signal3.png";
            }else if(signal < -95 && signal >= -105){
                signal = "signal2.png";
            }else if(signal < -105 && signal >= -115){
                signal = "signal1.png";
            }else if(signal < -115 && signal >= -140){
                signal = "signal0.png";
            }


            var electricity = parseInt(json[index].ele_charge);
            // if(electricity == undefined){
            //     electricity == 0;
            // }else {
            //     electricity == parseInt(json[index].ele_charge)
            // }
            // console.log(electricity)
            //根据电量多少 改变 图标（图片偏移）
            var elec = "";
            if(electricity == 0) elec = "-2px -10px";     
            else if(electricity > 0 && electricity <= 5) elec = "-40px -10px";
            else if(electricity > 5 && electricity <= 15) elec = "-78px -10px";
            else if(electricity > 15 && electricity <= 20) elec = "-116px -10px";
            else if(electricity > 20 && electricity <= 25) elec = "-2px -48px";
            else if(electricity > 25 && electricity <= 35) elec = "-40px -48px";
            else if(electricity > 35 && electricity <= 40) elec = "-78px -48px";
            else if(electricity > 40 && electricity <= 45) elec = "-116px -48px";
            else if(electricity > 45 && electricity <= 50) elec = "-2px -86px";
            else if(electricity > 50 && electricity <= 55) elec = "-40px -86px";
            else if(electricity > 55 && electricity <= 60) elec = "-78px -86px";
            else if(electricity > 60 && electricity <= 65) elec = "-116px -86px";
            else if(electricity > 65 && electricity <= 70) elec = "-2px -124px";
            else if(electricity > 70 && electricity <= 75) elec = "-40px -124px";
            else if(electricity > 75 && electricity <= 80) elec = "-78px -124px";
            else if(electricity > 80 && electricity <= 85) elec = "-116px -124px";
            else if(electricity > 85 && electricity <= 90) elec = "-2px -162px";
            else if(electricity > 90 && electricity <= 95) elec = "-40px -162px";
            else if(electricity > 95 && electricity < 100) elec = "-78px -162px";
            else if(electricity == 100) elec = "-116px -162px";

            var status = json[index].status == 1 ? "<span class='label label-success'>在线</span>" : "<span class='label label-inverse'>离线</span>";//状态

        res += "<tr>"
            + add_td((pageno-1)*10 + index+1)//id  序号
            + add_td(json[index].clientname)//客户名称
            + add_td(json[index].deviceid)//仪表编号
            + add_td(json[index].pos)//地理位置
            + add_td(json[index].time)//更新时间
            + add_td("<img src='assets/img/signal/"+signal+"' alt='信号' style='width:30px; height:20px;'>")//信号
            + add_td(json[index].press)//压力
            + add_td(json[index].temp)//温度
            + add_td(json[index].vol)//电量
            + add_td("<div alt='电量' style='width:34px; height:20px; background:url(assets/img/battery/dump-energy.png) no-repeat "+elec+";'></div>")//电池电压
            + add_td(json[index].col_cycle)//采集周期
            + add_td(status)//状态
            + add_td("<a href='history-data-chart.html?deviceId="+json[index].deviceid+"'><img src='assets/img/signal/3DChart.png' alt='查看曲线' title='查看曲线'></a>")//曲线
            + add_td("<a href='history-data-detail.html?deviceId="+json[index].deviceid+"'><img src='assets/img/signal/HistoricalReport.png' alt='查看历史数据' title='查看历史数据'></a>")//数据
        + "</tr>";
                      
    });

                      
    $("#item_table tbody").html(res);             
}
function set_status_data(json) {
    
}